]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Prefer g_steal_pointer where possible
authorBilal Elmoussaoui <belmouss@redhat.com>
Wed, 15 Apr 2026 07:37:00 +0000 (09:37 +0200)
committerBilal Elmoussaoui <belmouss@redhat.com>
Wed, 15 Apr 2026 07:37:00 +0000 (09:37 +0200)
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4176>

src/calendar-server/gnome-shell-calendar-server.c
src/shell-global.c
src/st/croco/cr-om-parser.c
src/st/croco/cr-parser.c
src/st/croco/cr-tknzr.c
src/st/st-icon.c
src/st/st-widget.c

index 4cd28d1c2748f5054a56c0d1491173d624cb22dc..0b2f88eb7e19396c9236c95bd0f6c5f9d4b7f426 100644 (file)
@@ -402,8 +402,7 @@ app_notify_events_removed (App *app)
   GVariantBuilder builder;
   GSList *ids, *link;
 
-  ids = app->notify_ids;
-  app->notify_ids = NULL;
+  ids = g_steal_pointer (&app->notify_ids);
 
   print_debug ("Emitting EventsRemoved with %d ids", g_slist_length (ids));
 
index 97b46e5ccdad534b5dd02bb076362b68330b09d4..fb8ea9a131b8292a66d8b80495976e562b16eedb 100644 (file)
@@ -1273,8 +1273,7 @@ run_leisure_functions (gpointer data)
   if (global->leisure_closures == NULL)
     return G_SOURCE_REMOVE;
 
-  closures = global->leisure_closures;
-  global->leisure_closures = NULL;
+  closures = g_steal_pointer (&global->leisure_closures);
 
   for (iter = closures; iter; iter = iter->next)
     {
index e9fdcd27b2a54c01d1cbcbce99bce64d2c6428ef..380bd4e5e184db4d27e6cdbfedfa53f17cea499d 100644 (file)
@@ -249,8 +249,7 @@ end_font_face (CRDocHandler * a_this)
         if (!stmts)
                 goto error;
 
-        ctxt->stylesheet->statements = stmts;
-        stmts = NULL;
+        ctxt->stylesheet->statements = g_steal_pointer (&stmts);
         ctxt->cur_stmt = NULL;
 
         return;
@@ -330,8 +329,7 @@ charset (CRDocHandler * a_this, CRString * a_charset,
                 }
                 return;
         }
-        ctxt->stylesheet->statements = stmt2;
-        stmt2 = NULL;
+        ctxt->stylesheet->statements = g_steal_pointer (&stmt2);
 }
 
 static void
@@ -404,8 +402,7 @@ end_page (CRDocHandler * a_this,
                                     ctxt->cur_stmt);
 
         if (stmt) {
-                ctxt->stylesheet->statements = stmt;
-                stmt = NULL;
+                ctxt->stylesheet->statements = g_steal_pointer (&stmt);
                 ctxt->cur_stmt = NULL;
         }
 
@@ -477,8 +474,7 @@ end_media (CRDocHandler * a_this, GList * a_media_list)
                 ctxt->cur_media_stmt = NULL;
         }
 
-        ctxt->stylesheet->statements = stmts;
-        stmts = NULL;
+        ctxt->stylesheet->statements = g_steal_pointer (&stmts);
 
         ctxt->cur_stmt = NULL ;
         ctxt->cur_media_stmt = NULL ;
@@ -526,16 +522,14 @@ import_style (CRDocHandler * a_this,
                 stmt2 = cr_statement_append (ctxt->cur_stmt, stmt);
                 if (!stmt2)
                         goto error;
-                ctxt->cur_stmt = stmt2;
-                stmt2 = NULL;
+                ctxt->cur_stmt = g_steal_pointer (&stmt2);
                 stmt = NULL;
         } else {
                 stmt2 = cr_statement_append (ctxt->stylesheet->statements,
                                              stmt);
                 if (!stmt2)
                         goto error;
-                ctxt->stylesheet->statements = stmt2;
-                stmt2 = NULL;
+                ctxt->stylesheet->statements = g_steal_pointer (&stmt2);
                 stmt = NULL;
         }
 
index 864e287e7c066be225d7901f555dbe02c4ebf966..ea196ec3fe6e27256adf3f8fe3b7efadefc41d18 100644 (file)
@@ -1364,8 +1364,7 @@ cr_parser_parse_attribute_selector (CRParser * a_this,
         ENSURE_PARSING_COND (status == CR_OK
                              && token && token->type == IDENT_TK);
 
-        result->name = token->u.str;
-        token->u.str = NULL;
+        result->name = g_steal_pointer (&token->u.str);
         cr_token_destroy (token);
         token = NULL;
 
@@ -1401,11 +1400,9 @@ cr_parser_parse_attribute_selector (CRParser * a_this,
         ENSURE_PARSING_COND (status == CR_OK && token);
         
         if (token->type == IDENT_TK) {
-                result->value = token->u.str;
-                token->u.str = NULL;
+                result->value = g_steal_pointer (&token->u.str);
         } else if (token->type == STRING_TK) {
-                result->value = token->u.str;
-                token->u.str = NULL;
+                result->value = g_steal_pointer (&token->u.str);
         } else {
                 status = CR_PARSING_ERROR;
                 goto error;
@@ -1734,8 +1731,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
                         add_sel = cr_additional_sel_new_with_type
                                 (ID_ADD_SELECTOR);
 
-                        add_sel->content.id_name = token->u.str;
-                        token->u.str = NULL;
+                        add_sel->content.id_name = g_steal_pointer (&token->u.str);
 
                         cr_parsing_location_copy 
                                 (&add_sel->location,
@@ -1760,8 +1756,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
                                 add_sel = cr_additional_sel_new_with_type
                                         (CLASS_ADD_SELECTOR);
 
-                                add_sel->content.class_name = token->u.str;
-                                token->u.str = NULL;
+                                add_sel->content.class_name = g_steal_pointer (&token->u.str);
 
                                 add_sel_list =
                                         cr_additional_sel_append
@@ -1826,12 +1821,10 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
 
                         if (token->type == IDENT_TK) {
                                 pseudo->type = IDENT_PSEUDO;
-                                pseudo->name = token->u.str;
-                                token->u.str = NULL;
+                                pseudo->name = g_steal_pointer (&token->u.str);
                                 found_sel = TRUE;
                         } else if (token->type == FUNCTION_TK) {
-                                pseudo->name = token->u.str;
-                                token->u.str = NULL;
+                                pseudo->name = g_steal_pointer (&token->u.str);
                                 cr_parser_try_to_skip_spaces_and_comments
                                         (a_this);
                                 status = cr_parser_parse_ident
@@ -1873,8 +1866,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
         if (status == CR_OK && found_sel == TRUE) {
                 cr_parser_try_to_skip_spaces_and_comments (a_this);
 
-                sel->add_sel = add_sel_list;
-                add_sel_list = NULL;
+                sel->add_sel = g_steal_pointer (&add_sel_list);
                 
                 if (*a_sel == NULL) {
                         *a_sel = sel;
@@ -2151,8 +2143,7 @@ cr_parser_parse_function (CRParser * a_this,
                 goto error;
 
         if (token && token->type == FUNCTION_TK) {
-                *a_func_name = token->u.str;
-                token->u.str = NULL;
+                *a_func_name = g_steal_pointer (&token->u.str);
         } else {
                 status = CR_PARSING_ERROR;
                 goto error;
@@ -3223,8 +3214,7 @@ cr_parser_parse_declaration (CRParser * a_this,
                 cr_term_append_term (*a_expr, expr);
                 expr = NULL;
         } else {
-                *a_expr = expr;
-                expr = NULL;
+                *a_expr = g_steal_pointer (&expr);
         }
 
         cr_parser_clear_errors (a_this);
@@ -3730,8 +3720,7 @@ cr_parser_parse_media (CRParser * a_this)
         ENSURE_PARSING_COND (status == CR_OK
                              && token && token->type == IDENT_TK);
 
-        medium = token->u.str;
-        token->u.str = NULL;
+        medium = g_steal_pointer (&token->u.str);
         cr_token_destroy (token);
         token = NULL;
 
@@ -3898,8 +3887,7 @@ cr_parser_parse_page (CRParser * a_this)
         ENSURE_PARSING_COND (status == CR_OK && token);
 
         if (token->type == IDENT_TK) {
-                page_selector = token->u.str;
-                token->u.str = NULL;
+                page_selector = g_steal_pointer (&token->u.str);
                 cr_token_destroy (token);
                 token = NULL;
         } else {
@@ -4149,8 +4137,7 @@ cr_parser_parse_charset (CRParser * a_this, CRString ** a_value,
         status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, &token);
         ENSURE_PARSING_COND (status == CR_OK
                              && token && token->type == STRING_TK);
-        charset_str = token->u.str;
-        token->u.str = NULL;
+        charset_str = g_steal_pointer (&token->u.str);
         cr_token_destroy (token);
         token = NULL;
 
@@ -4163,10 +4150,7 @@ cr_parser_parse_charset (CRParser * a_this, CRString ** a_value,
         cr_token_destroy (token);
         token = NULL;
 
-        if (charset_str) {
-                *a_value = charset_str;
-                charset_str = NULL;
-        }
+        *a_value = g_steal_pointer (&charset_str);
 
         PRIVATE (a_this)->state = CHARSET_PARSED_STATE;
         return CR_OK;
index ad800f93b746f1678faa087993dc65cfff128360..2c273c953f9a656637b9f447140b7524771af543 100644 (file)
@@ -756,8 +756,7 @@ cr_tknzr_parse_string (CRTknzr * a_this, CRString ** a_str)
 
         if (status == CR_OK) {
                 if (*a_str == NULL) {
-                        *a_str = str;
-                        str = NULL;
+                        *a_str = g_steal_pointer (&str);
                 } else {
                         (*a_str)->stryng = g_string_append_len
                                 ((*a_str)->stryng,
@@ -1207,8 +1206,7 @@ cr_tknzr_parse_uri (CRTknzr * a_this,
                 }
                 if (str) {                        
                         if (*a_str == NULL) {
-                                *a_str = str;
-                                str = NULL;
+                                *a_str = g_steal_pointer (&str);
                         } else {
                                 g_string_append_len
                                         ((*a_str)->stryng,
@@ -1982,8 +1980,7 @@ cr_tknzr_get_next_token (CRTknzr * a_this, CRToken ** a_tk)
                               CR_BAD_PARAM_ERROR);
 
         if (PRIVATE (a_this)->token_cache) {
-                *a_tk = PRIVATE (a_this)->token_cache;
-                PRIVATE (a_this)->token_cache = NULL;
+                *a_tk = g_steal_pointer (&PRIVATE (a_this)->token_cache);
                 return CR_OK;
         }
 
@@ -2683,8 +2680,7 @@ cr_tknzr_parse_token (CRTknzr * a_this, enum CRTokenType a_type,
                 case TIME_TK:
                 case FREQ_TK:
                         if (token->extra_type == a_et) {
-                                *((CRNum **) a_res) = token->u.num;
-                                token->u.num = NULL;
+                                *((CRNum **) a_res) = g_steal_pointer (&token->u.num);
                                 status = CR_OK;
                         }
                         break;
index d55ca419ed39c7777437bf8ff6dc67100054104d..be4297668eb404440c2354998df69f7a947a1b6f 100644 (file)
@@ -474,8 +474,7 @@ st_icon_finish_update (StIcon *icon)
 
   if (priv->pending_texture)
     {
-      priv->icon_texture = priv->pending_texture;
-      priv->pending_texture = NULL;
+      priv->icon_texture = g_steal_pointer (&priv->pending_texture);
       clutter_actor_set_x_align (priv->icon_texture, CLUTTER_ACTOR_ALIGN_CENTER);
       clutter_actor_set_y_align (priv->icon_texture, CLUTTER_ACTOR_ALIGN_CENTER);
       clutter_actor_add_child (CLUTTER_ACTOR (icon), priv->icon_texture);
index 72c7e8adc78c99069f636fb80f5aa2d977344282..ea162ec5956a0d9a11568fe4a4f761bdda378a4f 100644 (file)
@@ -524,11 +524,7 @@ st_widget_style_changed_internal (StWidget         *widget,
   StThemeNode *old_theme_node = NULL;
 
   priv->is_style_dirty = TRUE;
-  if (priv->theme_node)
-    {
-      old_theme_node = priv->theme_node;
-      priv->theme_node = NULL;
-    }
+  old_theme_node = g_steal_pointer (&priv->theme_node);
 
   /* update the style only if we are mapped */
   if (clutter_actor_is_mapped (CLUTTER_ACTOR (widget)))